function initialCompetitionOpt() {
    /*设置选项排序*/
    $( ".competition-option-card" ).sortable({
        items: "li:not(.add-competition-option)",
        cursor: "move"
    });
    $( ".competition-option-card" ).disableSelection();
    /*竞猜的添加和删除*/
    $('.add-competition-butten').on('click', function () {
        var btn='add-competition-butten';
        var preComptIndex=$('.add-competition').prev('.competition-form').data('index');
        var addObj = $(this).parent('.add-competition');
        $.get('/web/activity/competition', function (res) {
            addObj.before(res);
            initialOptionContainer(btn,preComptIndex);
        });
    });
    $('.competition-card').on('click', '.competition_card_delet', function () {
        if ($('.competition-form').length == 1) {
            return;
        }
        $(this).parents('.competition-form').remove();
    });
    /*竞猜选项的添加和删除*/
    $('.competition-card').on('click','.add-competition-option-butten',function () {
            var btn='add-competition-option-butten';
            var preComptIndex=$(this).parent('.add-competition-option').closest('.competition-form').data('index');
            var preOptionIndex=$(this).parent('.add-competition-option').prev('.competition-option-form').data('index');
            var addObj = $(this).parent('.add-competition-option');
            $.get('/web/activity/competition/option', function (res) {
                addObj.before(res);
                initialOptionContainer(btn,preComptIndex,preOptionIndex);
            });
    });
    $('.competition-card').on('click', '.competition_option_card_delet', function () {
        if ($(this).closest('.competition-option-card').children('.competition-option-form').length == 1) {
            return;
        }
        $(this).parents('.competition-option-form').remove();
    });
}
/*对新加的竞猜项或选项设置id、渲染插件*/
function initialOptionContainer(btn,preComptIndex,preOptIndex) {
    if(btn=='add-competition-butten'){
        var comptIndex=preComptIndex+1;
        var obj=$('.add-competition').prev('.competition-form');
        var objOption=obj.find('.competition-option-form');
        obj.attr('data-index',comptIndex);
        objOption.attr('data-index',0);
        console.log(comptIndex+'_option_container_0',8910);
        objOption.attr('id',comptIndex+'_option_container_0');
        initUploadImageFile('#'+comptIndex+'_option_container_0');
    }else if(btn=='add-competition-option-butten'){
        var obj=$('#'+preComptIndex+'_option_container_'+preOptIndex).next();
        var optIndex=preOptIndex+1;
        obj.attr('data-index',optIndex);
        obj.attr('id',preComptIndex+'_option_container_'+optIndex);
        initUploadImageFile('#'+preComptIndex+'_option_container_'+optIndex);
    }
    /*设置选项排序*/
    $( ".competition-option-card" ).sortable({
        items: "li:not(.add-competition-option)",
        cursor: "move"
    });
    $( ".competition-option-card" ).disableSelection();
}


